#include <ctype.h>
#include <stdio.h>

void reverse_word(char* s)
{
  char* e;
  char* f;
  char tmp;
  //loop invariant: s points to the end+1 of the previous word
  while(*s != '\0'){
    while(isspace(*s) )++s;//skip the space
    e=s;
    while( *e != '\0'&& !isspace(*e)) ++e;//find the end of the word
    f=e;
    for(--e;s<e;++s,--e){ //reverse a word
      tmp = *s;
      *s = *e;
      *e = tmp;
    }
    s = f;
    while(isspace(*s) )++s;//skip the space
  }
}

int main()
{
  char s[] = "";
  reverse_word(s);
  puts(s);
  return 0;
}
